// export const vollege_id = 2;
// export const title_name='石桥';

// export const vollege_id = 3;
// export const title_name='莲塘';

// export const vollege_id = 6;
// export const title_name='马畈';

// export const vollege_id = 8;
// export const title_name='大歇';

// export const vollege_id = 10;
// export const title_name='夹河';

// export const vollege_id = 13;
// export const title_name='琥珀';

// export const vollege_id = 14;
// export const title_name='叶坂';

// export const vollege_id = 15;
// export const title_name='城东';

// export const vollege_id = 43;
// export const title_name='创联山庄';

// export const vollege_id = 34;
// export const title_name='黄泥';

// export const vollege_id = 35;
// export const title_name='来榜';

// export const vollege_id = 36;
// export const title_name='响肠';

// export const vollege_id = 37;
// export const title_name='石盆';

export const vollege_id = 38;
export const title_name='河南';

/*export const vollege_id = 40;
export const title_name='城北';*/

// export const vollege_id = 41;
// export const title_name='西美';

// export const vollege_id = 42;
// export const title_name='方边';

 // export const vollege_id = 46;
 // export const title_name='梯岭';

// export const vollege_id = 43;
// export const title_name='王畈';


// localStorage 简易API封装
export const storage = {
  set(key, data) {
    window.localStorage.setItem(key, JSON.stringify(data))
  },
  get(key) {
    return JSON.parse(window.localStorage.getItem(key))
  },
  remove(key) {
    window.localStorage.removeItem(key)
  },
  clearAll() {
    window.localStorage.clear()
  }
}
// sessionStorage 简易API封装
export const sessionStorage = {
  set(key, data) {
    window.sessionStorage.setItem(key, JSON.stringify(data))
  },
  get(key) {
    return JSON.parse(window.sessionStorage.getItem(key))
  },
  remove(key) {
    window.sessionStorage.removeItem(key)
  },
  clearAll() {
    window.sessionStorage.clear()
  }
}
/**
 * 函数防抖
 * @param {callback} fn 事件回调
 * @param {number} delay 每次推迟执行的等待时间
 */
export const debounce = function(fn, delay) {
  let last = 0
  let timer = null
  return function() {
    const context = this
    const args = arguments
    const now = +new Date()

    if (now - last < delay) {
      clearTimeout(timer)
      timer = setTimeout(function() {
        last = now
        fn.apply(context, args)
      }, delay)
    } else {
      last = now
      fn.apply(context, args)
    }
  }
}
/**
 * 函数节流
 * @param {*} fn 事件回调
 * @param {*} interval 时间间隔的阈值
 */
export const throttle = function(fn, interval) {
  let last = 0
  return function() {
    const context = this
    const args = arguments
    const now = +new Date()

    if (now - last >= interval) {
      last = now
      fn.apply(context, args)
    }
  }
}

  /**
   * 获取当前年退后前十年的年份数组
   */
export const selectYear = function(n,m) {
    if(m==='' || m===undefined)
      m=0;
    var myDate= new Date();
    var startYear=myDate.getFullYear()-n;//起始年份
    var endYear=myDate.getFullYear()+m;//结束年份
    var arr = new Array();
    for (var i=startYear;i<=endYear;i++) {
      var obj = {"value":i,"label":i};
      arr.push(obj);
    }
    return arr;
}


/**
 * 获取当前年退后前十年的年份数组
 */
export const selectYear2 = function(n,m) {
  if(m==='' || m===undefined)
    m=0;
  var myDate= new Date();
  var startYear=myDate.getFullYear()-n;//起始年份
  var endYear=myDate.getFullYear()+m;//结束年份
  var arr = new Array();
  for (var i=startYear;i<=endYear;i++) {
    var obj = {"value":i,"label":i};
    arr.push(obj);
  }
  return arr;
}




/**
 * 获取当前年退后前十年的年份数组
 */
export const selectYearMonth = function() {
  var result = [];
        for(var i = 0; i < 12; i++) {
               var d = new Date();
               d.setDate(1);
               d.setMonth(d.getMonth() - i);
               var m = d.getMonth() + 1;

               m = m < 10 ? "0" + m : m;
               //在这里可以自定义输出的日期格式
               result.push({"value":i,"label":d.getFullYear() + "-" + m});
               //result.push(d.getFullYear() + "年" + m + '月');
           }
         return result;
}




//获取url链接后的参数
//获取url链接后的参数
export const getUrlParam=(name,url)=>{
  let intPos = url.indexOf("?");
  let strRight = url.substr(intPos + 1);
  let arrTmp = strRight.split('&');
  for (var i = 0; i <arrTmp.length ; i++) {
    let arrTemp = arrTmp[i].split("=");
    if (arrTemp[0].toUpperCase() == name.toUpperCase())
      return arrTemp[1];
  }
  return '';
}
// localStorage 简易API封装



export const getNextDate=(date,day)=> {
  var dd = new Date(date);
  dd.setDate(dd.getDate() + day);
  var y = dd.getFullYear();
  var m = dd.getMonth() + 1 < 10 ? "0" + (dd.getMonth() + 1) : dd.getMonth() + 1;
  var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();
  return y + "-" + m + "-" + d;
}





export default {
  //baseURL,
  vollege_id,
  storage,
  sessionStorage,
  selectYear,
  selectYear2,
  selectYearMonth,
  title_name,
  debounce,
  throttle,
  getUrlParam,
  getNextDate

}




